package com.fh.service.airsys.common;

import com.fh.entity.airsys.SmsModel;
import com.model.CommonKeyData;
import com.model.DTOApiResponse;
import com.service.PostConnServer;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SendSMS {

    private final String roun="APP_SmsSend";
    private final String appid="com_ykt_html_caroilcard";
    private final String token="547L4639VN";
    private final String key="OL57AW3EFGPQ2955";
    private final String termNo="42B8906E-67AA-5CBA-7DA0-4372AABB109B";
    private final String website="http://xapps.yktcards.com/AppSys/api/index";

    public Integer send(String num, List<String> smsContentList, String tempId){
        CommonKeyData data = new CommonKeyData();
        data.setWebsite(website);
        data.setAppid(appid);
        data.setKey(key);
        data.setToken(token);
        data.setTermNo(termNo);
        SmsModel sms = new SmsModel();
        sms.setSmsContentList(smsContentList);
        sms.setSmsNum(num);
        sms.setTempId(tempId);
        try {
            DTOApiResponse response = PostConnServer.getRequestData(sms,roun,data);
            if(response.getCode() != null && !response.getCode().equals("00000")){
                return 0;
            }
            else{
                return 1;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }

    public static void main(String[] args) {
        String num = "13086017400";
        List<String> list = new ArrayList<String>();
        list.add("123321");
        list.add("3");
        String tempId = "1";
        SendSMS sms = new SendSMS();
        sms.send(num,list,tempId);
    }
}
